﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Configuration;
using AmuTools;

namespace app.Models
{
    [Model(TableName = "lanmuInfo", PrimaryKey = "id", Description = "所有数据")]
    public class AllInOne
    {
        public string id { get; set; }

        [Field(Description = "分类id")]
        public string fid { get; set; }

        [Field(Description ="标题")]
        public string title { get; set; }

        [Field(Description = "阅读量")]
        public string readcount { get; set; }

        [Field(Description = "发布时间", Webable = false, Nullable = false, Default = "")]
        public string time { get; set; }

        [Field(Description = "只显示日期的发布时间", Storageable = false)]
        public string date { get { return time.Split(' ')[0]; } }

        [Field(Description = "内容", Default = "", Webable = false
            )]
        public string content { get; set; }

        [Field(Description = "替换资源路径的内容", Storageable = false)]
        
        public string replaced_content {
            get
            {
                return content.Replace("=\"/uploadfiles/", string.Format("=\"{0}/uploadfiles/", ConfigurationManager.AppSettings["FilesURL"]))
                    .Replace("=\"uploadfiles/",string.Format("=\"{0}uploadfiles/",ConfigurationManager.AppSettings["FilesURL"] + "/"))
                    .Replace("=\"../uploadfiles/", string.Format("=\"{0}/uploadfiles/", ConfigurationManager.AppSettings["FilesURL"]))
                    .Replace("=\"/osCAI/uploadfiles/", string.Format("=\"{0}/osCAI/uploadfiles/", ConfigurationManager.AppSettings["FilesURL"]))
                    .Replace("=\"/oscai/uploadfiles/", string.Format("=\"{0}/oscai/uploadfiles/", ConfigurationManager.AppSettings["FilesURL"]))
                    .Replace("=\" uploadfiles/", string.Format("=\"{0}uploadfiles/", ConfigurationManager.AppSettings["FilesURL"] + "/"));
            }
        }
    }
}